# udev rules for hotplugging Tascam USB audio devices.

# This file is part of the slackbuilds.org alsa-tools build, released
# under the WTFPL. See http://sam.zoy.org/wtfpl/ for details.

# The vendor/product IDs were taken from /usr/share/usb.ids. The rules
# were adapted from http://www.astro.caltech.edu/~mcs/tascam_us122/
# (no idea who the author is, no name given on the page).

# Tascam's USB Vendor ID is 1604.
# Each device has two product IDs: first the initial product ID when it's
# plugged in. Then after the 1st stage firmware is loaded with fxload,
# the device re-identifies itself with a second product ID... when udev
# sees this, we want it to load the 2nd stage firmware with usx2yloader.

# Device           Inititial ID   2nd-stage ID
# Tascam US-122    8006           8007
# Tascam US-224    8004           8005
# Tascam US-428    8000           8001

# Note that I haven't tested the 224 or 428 rules, because I don't own
# either of these devices. If you end up having to modify the rules to
# make them work, please send me your modified version of this file
# so I can include it in a future version of my SlackBuild. Of course,
# you don't *have* to do this (the WTFPL doesn't require it), I'm just
# asking you nicely :)

# US-122:
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8006", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us122fw.ihx'"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8007", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/usr/bin/usx2yloader'"

# US-224:
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8004", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us224fw.ihx'"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8005", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/usr/bin/usx2yloader'"

# US-428. Note that we aren't starting the us428control daemon, so
# the control surfaces won't work as MIDI controls.
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8000", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us428fw.ihx'"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8001", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/usr/bin/usx2yloader'"

